package tcm.com.gistone.database.mapper;

import java.util.List;

import org.apache.ibatis.annotations.*;
import tcm.com.gistone.database.entity.WsRelation;

public interface WsRelationMapper {
    int deleteByPrimaryKey(Long id);

    int insert(WsRelation record);

    int insertSelective(WsRelation record);

    WsRelation selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(WsRelation record);

    int updateByPrimaryKey(WsRelation record);

    /*批量插入*/
    int insertBatch(List<WsRelation> list);

    /*查询出现某词的所有记录*/
    @Select("SELECT * FROM tb_ws_relation WHERE word_id = #{wordId}")
    @ResultMap("tcm.com.gistone.database.mapper.WsRelationMapper.BaseResultMap")
    List<WsRelation> selectByWId(Long wordId);


    @Select("SELECT SUM(word_num) FROM tb_ws_relation WHERE word_id = #{wordId}")
    int selectSumByWId(Long wordId);

    /*查询出现在某段中的所有记录*/
    @Select("SELECT * FROM tb_ws_relation WHERE section_id = #{sectionId}")
    @ResultMap("tcm.com.gistone.database.mapper.WsRelationMapper.BaseResultMap")
    List<WsRelation> selectBySId(Long sectionId);

    @Select("SELECT * FROM tb_ws_relation WHERE section_id = #{sectionId} and word_id = #{wordId}")
    @ResultMap("tcm.com.gistone.database.mapper.WsRelationMapper.BaseResultMap")
    WsRelation selectBySWId(@Param("sectionId") long sectionId, @Param("wordId") long wordId);
}